#include "mainwindow.h"

#include <QApplication>
#include <QFile>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    //引入我们需要的qss样式文件
    QFile qss(":/style/stylesheet.qss");

    if(qss.open(QFile::ReadOnly)){
        //将QByteArray转换成QString
        QString qStyle = QLatin1String(qss.readAll());
        a.setStyleSheet(qStyle);
        qss.close();
    }else{
        qDebug()<<"打开失败";
    }

    //读取外部的ini配置
    QString fileName = "config.ini";
    QString app_path = QCoreApplication::applicationDirPath();
    //正反斜杠，qt提供,自适应的斜杠
    QString config_path = QDir::toNativeSeparators(app_path + QDir::separator() + fileName);
    // 读取ini文件
    QSettings settings(config_path,
                       QSettings::IniFormat);
    QString get_host = settings.value("GateServer/host").toString();
    QString get_port = settings.value("GateServer/port").toString();
    //由于是全局的
    gate_url_prefix = "http://"+get_host+":"+get_port;


    MainWindow w;
    w.show();
    return a.exec();
}
